package com.qf.fmmall.controller;/*
 *徐韬
 *2022/1/23
 *13:14
 */

import com.qf.fmmall.LoginVO.resultVO;
import com.qf.fmmall.service.userService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
@Api(value = "用户信息接口",tags = "用户登录与注册")
public class UserController {
    @Autowired
    private userService userService;


    @GetMapping("/login")
    @ApiOperation(value = "登录")
    @ApiImplicitParams({
            @ApiImplicitParam(dataType = "String",name = "username",required = true,value = "用户名"),
            @ApiImplicitParam(dataType = "String",name = "password",required = true,value = "密码")
    })
    public resultVO  login(String username,String password){
        resultVO resultVO = userService.login(username, password);
        return resultVO;
    }


    @PostMapping("/regist")
    @ApiOperation(value = "注册")
    @ApiImplicitParams({
            @ApiImplicitParam(dataType = "String",name = "username",required = true,value = "用户名"),
            @ApiImplicitParam(dataType = "String",name = "password",required = true,value = "密码")
    })
    public resultVO regist(String username,String password){
        resultVO regist = userService.regist(username, password);
        return regist;


    }
}
